</head>
<body>
<style>
.image_pic { position:absolute; right:0px; bottom:-1px; background-color:#FFF; padding:3px; border:1px solid #ddd; width:146px; height:146px;}
</style>
<div class="f-sep10"></div>
<div class="f-sep10"></div>
<div class="m-hd m-tabs">
  <h2 class="u-tt">{$action_name}内容</h2>
  <ul id="tabs">
    <li> <a class="z-crt" href="#tab1"><span class="icon">&#xf05a;</span> 基本信息</a></li>
    <li> <a href="#tab2"> <span class="icon">&#xf0ad;</span> 高级设置</a></li>
	<li><a href="{$url(admin_content/index)}"><span class="icon">&#xf101;</span> 内容列表</a></li>
  </ul>
</div>
<div class="f-sep10"></div>
<div class="m-form">
  <form action="<?php echo url('admin_content/'.$action.'_save'); ?>" method="post" id="form">
    <fieldset>
      <div id="tab1">
        <div class="formitm">
          <label class="lab" >栏目：</label>
          <div class="ipt">
            <div class="txt">
              <select name="cid"  datatype="*" nullmsg="请选择栏目！" errormsg="请选择栏目！" id="cid"  onChange="get_fields()" >
                <option value="">======选择栏目======</option>
                <!--foreach:{$category_list $vo}-->
                <option  <?php if($category_info['cid']==$vo['cid']) { ?> selected="selected" <?php } ?> 
                                  <?php if($vo['type']==0 || $vo['mid']<>$model_info['mid']){ ?> value="0" style="background-color:#ccc"  disabled="disabled" <?php }else{ ?>  value="{$vo['cid']}"<?php } ?> >
                                  {$vo['cname']}
                </option>
                <!--{/foreach}-->
              </select>
              <span class="Validform_checktip"></span> 
            </div>
            </div>
        </div>
		<?php ApiHook('hook_admin_content_info_top_html',$info); ?>
        <div class="formitm">
          <label class="lab" >标题：</label>
          <div class="ipt">
            <?php
          $title_type='';
          if(!empty($info['font_color'])){
          	$title_type.='color:'.$info['font_color'].';';
          }
          if(!empty($info['font_bold'])){
          	$title_type.="font-weight:bold  !important;";
          }
		  $title_type='style="'.$title_type.'"';
           ?>
            <input name="title" type="text" class="u-ipt" id="title" value="{$info.title}"  {$title_type} datatype="*" errormsg="内容标题未填写" /><span class="u-ico f-csp" id="corol_button"><span class="icon">&#xf043;</span> 颜色</span><span class="u-ico f-csp" id="bold_button"><span class=" icon">&#xf032;</span> 加粗</span> <span class="Validform_checktip"></span> </div>
          <input id="font_color" name="font_color" type="hidden" value="{$info.font_color}" />
          <input id="font_bold" name="font_bold" type="hidden" value="{$info.font_bold}" />
        </div>
        <div class="formitm" style="position:relative">
          <label class="lab" >封面图：</label>
          <div class="ipt">
		<input name="image" id="image" type="text" class="u-ipt" value="{$info.image}" /><span class="u-ico f-csp" id="image_button"><span class=" icon">&#xf093;</span> 上传</span><span class="u-ico f-csp" id="image_cutout"><span class=" icon">&#xf03e;</span> 处理</span> <div>
		</div>
			</div>
		<div class="image_pic"><img id="image_pic" src="<?php if($info['image']){echo $info['image']; }else{ ?>__PUBLIC__/images/no-pic.gif <?php } ?>" width="146" height="146"></div>
		
        </div>
        <div class="formitm">
          <label class="lab" >内容：</label>
          <div class="ipt">
            <textarea class="u-editor" name="content" id="content" style="width:100%; height:350px;">{$page_info.content}</textarea>
            <div class="u-editor-tool">
            提取第 <input name="tool_image" type="text" class="u-ipt u-ipt-2" value="1" /> 张图片作为封面图，截取 <input name="tool_description" type="text" class="u-ipt u-ipt-2"  datatype="n1-5" errormsg="最少填写1位数" value="250" /> 个字符为描述，<input name="tool_page" type="checkbox" value="1"> 自动分页，按照每 <input name="tool_page_num" id="tool_page_num" type="text" class="u-ipt u-ipt-2"  datatype="n1-5" errormsg="最少填写1位数" value="10000" /> 个字符
            </div>
          </div>
        </div>
        <div class="formitm">
          <label class="lab" >内容来源：</label>
          <div class="ipt">
            <input name="copyfrom" type="text" class="u-ipt" id="copyfrom" value="{$info.copyfrom}" />
            <span class="Validform_checktip">选择或输入内容来源</span> </div>
        </div>
		<div id="expand"></div>
		<?php ApiHook('hook_admin_content_info_foot_html',$info); ?>
        <div class="formitm">
          <label class="lab" >关键词：</label>
          <div class="ipt">
            <input name="keywords" id="keywords" type="text" class="u-ipt" value="{$info.keywords}" /><span id="get_keywords" class="u-ico f-csp" id="corol_button"><span class="icon">&#xf090;</span> 提取</span>
            <?php if($info['taglink']){ ?>
            &nbsp;&nbsp;
            <input name="taglink" type="checkbox" value="1" checked="checked" />
            <?php }else{ ?>
            &nbsp;&nbsp;
            <input name="taglink" type="checkbox" value="1" />
            <?php } ?>
            内容自动链接 </div>
        </div>
        <div class="formitm">
          <label class="lab" >描述：</label>
          <div class="ipt">
            <textarea name="description" id="description" class="u-itt" >{$info.description}</textarea>
            <span class="Validform_checktip"><a href="javascript:;" id="get_description">提取描述</a></span> </div>
        </div>
        <div class="formitm">
          
          <label class="lab" >状态：</label>
          <div class="ipt">
            <?php if(!isset($info['status'])){ $info['status']=1; } ?>
            <input name="status" type="radio" value="1"  <!--if:{$info['status']==1}-->checked="checked"<!--{/if}--> /> 发布&nbsp;&nbsp;<input name="status" type="radio"  <!--if:{$info['status']==0}-->checked="checked"<!--{/if}--> /> 草稿&nbsp;&nbsp; </div>
        </div>
      </div>
      <div id="tab2">
        <div class="formitm">
          <label class="lab" >副标题：</label>
          <div class="ipt">
            <input name="subtitle" type="text" class="u-ipt" value="{$info.subtitle}" />
            <span class="Validform_checktip">页面头部信息的副标题</span> </div>
        </div>
        <div class="formitm">
          <label class="lab" >内容URL优化：</label>
          <div class="ipt">
            <input name="urltitle" type="text" class="u-ipt" value="{$info.urltitle}" />
            <span class="Validform_checktip">内容英文名称，不能含有特殊符号</span> </div>
        </div>
        <div class="formitm">
          <label class="lab" >访问量：</label>
          <div class="ipt">
            <input name="views" type="text" class="u-ipt" value="{$info.views isset="0"}" />
            <span class="Validform_checktip">内容浏览次数</span> </div>
        </div>
        <div class="formitm">
          <label class="lab" >顺序：</label>
          <div class="ipt">
            <input name="sequence" type="text" class="u-ipt" value="{$info.sequence isset="0"}" />
            <span class="Validform_checktip">按照自定义数字排序</span> </div>
        </div>
        <div class="formitm">
          <label class="lab" >跳转到：</label>
          <div class="ipt">
            <input name="url" type="text" class="u-ipt" id="url" value="{$info.url}"  />
            <span class="Validform_checktip">URL链接，支持标签</span> </div>
        </div>
        <div class="formitm">
          <label class="lab" >更新时间：</label>
          <div class="ipt">
            <input name="updatetime" type="text" class="u-ipt" id="updatetime" value="<?php echo date('Y-m-d H:i:s'); ?>" datatype="*" errormsg="更新时间不能为空！"   /><span id="time_button" class="u-ico f-csp"><span class="icon">&#xf017;</span> 选择</span>
            <span class="Validform_checktip">内容最后的更新时间</span> </div>
        </div>
        <div class="formitm">
          <label class="lab" >内容模板：</label>
          <div class="ipt">
            <input name="tpl" type="text" class="u-ipt" id="tpl" value="{$info.tpl}" />
            <span class="Validform_checktip">留空采用栏目指定模板</span> </div>
        </div>
      </div>
      <div class="formitm formitm-1">
        <button class="u-btn" id="submit" type="submit">保存修改</button>
        <button class="u-btn u-btn-c4" id="reset" type="button">重置</button>
        <span id="tip" class="load"></span> </div>
    </fieldset>
    <input name="aid" type="hidden" value="{$info.aid}" />
    <input name="file_id" id="file_id" type="hidden" value="{$file_id}" />
  </form>
</div>
<div id="expand_js"></div>
</body>
<?php echo api('editor','get_editor','content'); ?>
<?php echo api('editor','get_upload_image',array('button'=>'image_button','id'=>'image','editor'=>'content','pic'=>'image_pic')); ?>
<?php echo api('editor','get_image_cutout',array('button'=>'image_cutout','id'=>'image','pic'=>'image_pic')); ?>
<script>
var get_fields = new function(){}; 
var tpl_val = new function(){}; 
var befrom_val = new function(){}; 
var image_val =  new function(){}; 
Do.ready('base','form','color','tabs','calendar','dialog','tip', function() {
	saveform('{$url(admin_content/index)}');
	tabs();
	
	//颜色
	$('#corol_button').soColorPacker({
	textChange:false, 
	callback:function(c){
		$('#title').css("color", c.color);
		$('#font_color').val(c.color);
		}
	});
	//加粗
	$('#bold_button').click(function(){
		if($('#font_bold').val()==0){
			$('#title').css("font-weight",'bold');
			$('#font_bold').val(1);
			}else{
			$('#title').css("font-weight",'normal');	
			$('#font_bold').val(0);
		}
	});

	//提取关键词
	$('#get_keywords').click(function(){
		$.post(
		'{$url(admin/content/get_keyword)}',
		{title:$('#title').val(),content:$('#description').val()},
		function(json){
			if(json.status=='y'){
				$('#keywords').val(json.info);
			}else{
				art.dialog.tips(json.info, 3);
			}
		},'json'
		);
	})
	
	//提取描述
	$('#get_description').click(function() {
        var content=editor_content.text();
		content=content.substring(0,500);
		content=content.replace(/\s+/g," ")
		content=content.replace(/[\r\n]/g," ");
		content = content.replace(/<\/?[^>]*>/g,'');
		if(content.length > 250){
			content = content.substring(0,250);
		}
		$("#description").val(content);
    });

	//时间选择
	$('#time_button').calendar({ id:'#updatetime',format:'yyyy-MM-dd HH:mm:ss'});


	//模板赋值
	window.tpl_val = function tpl_val(id,val){
		$('#'+id).val(val);
		$.powerFloat.hide();
	}
	function tpl_list(id){
		var list = [ 
		<!--foreach:{$tpl_list $vo}-->
		{
			href: "javascript:tpl_val('"+id+"','{$vo}');",
			text: "{$vo}"
		},
		<!--{/foreach}-->
		{
			text: "请选择使用模板"
		}];
		return list;
	}
	function tpl_power(id){
		$("#"+id).powerFloat({
			width: 308,
			eventType: "click",
			edgeAdjust:false,
			reverseSharp:true,
			target:tpl_list(id),
			targetMode: "list"
		});
	}
	tpl_power("tpl");
	
	//内容来源列表	
	function befrom_list(id){
		var list = [ 
		<!--foreach:{$befrom_list $vo}-->
		{
			href: "javascript:befrom_val('"+id+"','{$vo}');",
			text: "{$vo}"
		},
		<!--{/foreach}-->
		{
			text: "请选择内容来源"
		}];
		return list;
		
	}
	//来源赋值
	window.befrom_val = function befrom_val(id,val){
		$('#'+id).val(val);
		$.powerFloat.hide();
	}
	//来源选择
	$("#copyfrom").powerFloat({
		width: 308,
		eventType: "click",
		edgeAdjust:false,
		target:befrom_list('copyfrom'),
		targetMode: "list"
	});
	
	//缩略图处理
	window.image_val = function image_val(id,val){
		$('#'+id).val(val);
		$('#image_pic').attr('src',val);
		$.powerFloat.hide();
	}
	$("#image").blur(function(){
		var image=$('#image').val();
		if(image){
			$('#image_pic').attr('src',$('#image').val());
		}else{
			$('#image_pic').attr('src','__PUBLIC__/images/no-pic.gif');
		}
	});
	$("#image").powerFloat({
		width: 308,
		eventType: "click",
		edgeAdjust:false,
		target:function() {
			var list = [];
			var file_id = $('#file_id').val();
			if(!file_id){
				list.push({'text': "请先上传图片"});
			}else{
				$.ajax({
					type:"POST",
					async:false,
					url:'{$url(editor/upload/get_list_type)}',
					data:{id:file_id,ext:'jpg,gif,png,bmp,jpeg'},
					dataType:'json',
					success:function(data){
						if(data.status=='y'){
							for (var i in data.info) {
								list.push({'href':"javascript:image_val('image','"+data.info[i].file+"');",'text':data.info[i].title+'.'+data.info[i].ext});
							}
						}else{
							list.push({'text': "请先上传图片"});
						}
					}
				});
			}
			return list;
		},
		targetMode: "list"
	});

	//获取栏目联动
	window.get_fields = function get_fields() {
		var cid = $('#cid').val();
		var aid = '{$info.aid}';
		
		<?php ApiHook('hook_admin_content_info_js_class',$info); ?>
	}
	get_fields();

});

</script>